package com.gduf.bbl.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

@EnableSwagger2
@Configuration
public class SwaggerConfig {
    //配置文档信息

    //配置生成接口规则

    /*Docket封装接口文档信息*/
    @Bean
    public Docket getDocket(){
        Docket docket = new Docket(DocumentationType.SWAGGER_2);//指定文档风格

        ApiInfoBuilder apiInfoBuilder = new ApiInfoBuilder();
        apiInfoBuilder.title("后端接口说明")//标题
                .description("说明了后端接口规范").//形容信息
                version("v 1.0.0").//版本
                contact(new Contact("xqw","www.xqw.com","2041411595@qq.com"));//作者的信息

        ApiInfo apiInfo = apiInfoBuilder.build();//工厂模式

        docket.apiInfo(apiInfo)//指定生成接口文档的封面信息
            .select()
            .apis(RequestHandlerSelectors.basePackage("com.gduf.bbl.controller"))//扫描哪些包
            .paths(PathSelectors.regex("/bbl"));//指定对哪些路径下的请求进行进行处理


        return docket;
    }


}
